package com.ruoyi.manager.controller;

import java.util.List;

import com.ruoyi.manager.service.ISoldierSpecialCareInfoService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.manager.domain.SoldierSpecialCareInfo;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 优抚信息Controller
 *
 * @author Allen
 * @date 2021-08-30
 */
@RestController
@RequestMapping("/manager/retirefm_1")
public class SoldierSpecialCareInfoController extends BaseController {
    @Autowired
    private ISoldierSpecialCareInfoService soldierSpecialCareInfoService;

    /**
     * 查询优抚信息列表
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_1:list')")
    @GetMapping("/list")
    public TableDataInfo list(SoldierSpecialCareInfo soldierSpecialCareInfo) {
        startPage();
        List<SoldierSpecialCareInfo> list = soldierSpecialCareInfoService.selectSoldierSpecialCareInfoList(soldierSpecialCareInfo);
        return getDataTable(list);
    }

    /**
     * 导出优抚信息列表
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_1:export')")
    @Log(title = "优抚信息", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SoldierSpecialCareInfo soldierSpecialCareInfo) {
        List<SoldierSpecialCareInfo> list = soldierSpecialCareInfoService.selectSoldierSpecialCareInfoList(soldierSpecialCareInfo);
        ExcelUtil<SoldierSpecialCareInfo> util = new ExcelUtil<SoldierSpecialCareInfo>(SoldierSpecialCareInfo.class);
        return util.exportExcel(list, "优抚信息数据");
    }

    /**
     * 获取优抚信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_1:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(soldierSpecialCareInfoService.selectSoldierSpecialCareInfoById(id));
    }

    /**
     * 新增优抚信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_1:add')")
    @Log(title = "优抚信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SoldierSpecialCareInfo soldierSpecialCareInfo) {
        return toAjax(soldierSpecialCareInfoService.insertSoldierSpecialCareInfo(soldierSpecialCareInfo));
    }

    /**
     * 修改优抚信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_1:edit')")
    @Log(title = "优抚信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SoldierSpecialCareInfo soldierSpecialCareInfo) {
        return toAjax(soldierSpecialCareInfoService.updateSoldierSpecialCareInfo(soldierSpecialCareInfo));
    }

    /**
     * 删除优抚信息
     */
    @PreAuthorize("@ss.hasPermi('manager:retirefm_1:remove')")
    @Log(title = "优抚信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(soldierSpecialCareInfoService.deleteSoldierSpecialCareInfoByIds(ids));
    }
}
